/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.bluepumpkin.beans;

import com.aptech.bluepumpkin.Winner;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

/**
 *
 * @author Trong Nguyen
 */
@Stateless
public class WinnerFacade extends AbstractFacade<Winner> {
    @PersistenceContext(unitName = "BluePumkin-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public WinnerFacade() {
        super(Winner.class);
    }
    public List<Winner> getAllWinners(){
        String sql = "SELECT w FROM Winner w ORDER BY w.id DESC";
        TypedQuery<Winner> createNamedQuery = em.createQuery(sql, Winner.class);
        return createNamedQuery.getResultList();
    }
}
